home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / C / COP.ZIP / SHAPE.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-20  |  1.1 KB  |  50 lines

  1. #include <graphics.h>
  2.  
  3. #ifndef shape_HPP
  4. #define shape_HPP
  5.  
  6. class Shape {
  7.     unsigned x, y;
  8. public:
  9.     Shape(unsigned x = 0, unsigned y = 0)
  10.         { this->x = x; this->y = y; }
  11.     unsigned getx() { return x; }
  12.     unsigned gety() { return y; }
  13.     virtual void show(int xxpose = 0,
  14.         int yxpose = 0, unsigned scale = 1) {}
  15.     virtual ~Shape() {}
  16. };
  17.  
  18. class Segment : public Shape  {
  19.     Shape ** shapes;
  20.     unsigned shapeCount;
  21. public:
  22.     Segment(unsigned x, unsigned y,
  23.         unsigned shapeCount, .../* shapes */);
  24.     // All shapes must be dynamically allocated!
  25.     // Segment then owns these shapes for deletion
  26.     // purposes.
  27.     virtual void show(int xxpose = 0,
  28.         int yxpose = 0, unsigned scale = 1);
  29.     ~Segment();
  30. };
  31.  
  32. class Circle : public Shape  {
  33. protected:
  34.     unsigned radius;
  35. public:
  36.     Circle(unsigned radius
  37.             = (unsigned) getmaxy()/8,
  38.         unsigned x = 0, unsigned y = 0)
  39.         : Shape((x?x:radius),(y?y:radius))
  40.         { this->radius = radius; }
  41.     virtual void show(int xxpose = 0,
  42.         int yxpose = 0, unsigned scale = 1)
  43.         {
  44.             circle((int)getx()+xxpose,
  45.                 (int)gety()+yxpose,
  46.                 (int)(radius*scale));
  47.         }
  48. };
  49.  
  50. #endif